<template>

  <el-container>
    <el-header>
      <div>
        <el-menu
          :default-active="activeIndex2"
          class="el-menu-demo"
          mode="horizontal"
          @select="handleSelect"
          background-color="#545c64"
          text-color="#fff"
          active-text-color="#ffd04b">
          <el-menu-item index="1" @click="ProcessingCenter()">处理中心</el-menu-item>
          <el-submenu index="2">
            <template slot="title">我的工作台</template>
            <el-menu-item v-if="!role.isManager" index="2-1" @click="getUuer()">个人信息展示</el-menu-item>
            <el-menu-item v-if="!role.isManager" index="2-2" @click="setAccountName()">修改用户名</el-menu-item>
            <el-menu-item v-if="!role.isManager" index="2-3" @click="setPhone()">修改手机号</el-menu-item>
            <el-menu-item v-if="!role.isManager" index="2-4" @click="setEmail()">修改邮箱</el-menu-item>
            <el-menu-item v-if="!role.isManager" index="2-5" @click="setPassword()">修改密码</el-menu-item>
            <el-menu-item v-if="role.isManager" index="2-6" @click="jumpTo()">添加维修员</el-menu-item>
            <el-menu-item v-if="role.isManager" index="2-7" @click="addNotice()">新增公告</el-menu-item>
            <el-menu-item v-if="role.isManager" index="2-8" @click="guidanceAdd()">新增服务指南</el-menu-item>
            <el-menu-item v-if="role.isManager" index="2-9" @click="accountManageement()">账号管理</el-menu-item>
          </el-submenu>
          <el-menu-item index="3" disabled>消息中心</el-menu-item>
          <el-menu-item index="4" @click="goMain()">主页</el-menu-item>
        </el-menu>
      </div>
    </el-header>
    <el-main>
      <router-view/>
    </el-main>
  </el-container>

</template>

<script>
  export default{
    name:"PersonalCenter",
    data(){
    	return{
        userName:sessionStorage.getItem("userName"),
        user:JSON.parse(localStorage.getItem("user")).data,
        role:{
          isStudent: JSON.parse(localStorage.getItem("user")).data.state == 2 ? true : false,
          isManager: JSON.parse(localStorage.getItem("user")).data.state == 0 ? true : false,
          isRepairer: JSON.parse(localStorage.getItem("user")).data.state == 1 ? true : false
        }
    	}
    },
    methods:{
      //点击处理中心
      ProcessingCenter(){
        alert("该功能正在开发中")
      },
      jumpTo(){
        this.$router.push("/repairpeople")
      },
      //账号管理
      accountManageement(){
        this.$router.push("/accountManageement")
      },
      //新增服务指南
      guidanceAdd(){
         this.$router.push("/guidanceAdd")
      },
      //新增公告
      addNotice(){
        this.$router.push("/addNotice")
      },
      //点击个人信息展示
      getUuer(){
        this.$router.push("/PersonalInformation")
      },
      //修改手机号
      setPhone(){
        this.$router.push("/SetPhone")
      },
      //修改密码
      setPassword(){
        this.$router.push("/SetPassword")
      },
      //修改邮箱
      setEmail(){
        this.$router.push("/SetEmail")
      },
      //修改用户名
      setAccountName(){
        this.$router.push("/SetAccountName")
      },
      //去主页
    	goMain(){
        this.$router.push("/index")
      }
    }
  }

</script>

<style>
</style>
